<strong>Comments</strong>
<?php 
foreach($comments as $i => $comment)
{
?>
<div id="comment_<?php echo $comment['iId']?>"  style="border-top: 1px solid #dddddd; padding:10px">
    <div>
        <span style="font-weight: 600; color:#176B9B;">
            <?php echo $comment['cFullName']?> - 
            <?php echo $comment['cEmail']?>
        </span>
        #  
        <?php echo $comment['dPostDate']?>
         &raquo; 
        <?php echo linkAction('show',Show,'&id='.$comment)?> | 
        <a style="cursor: pointer;" onclick="editComment(<?php echo $comment['iId']?>)">Edit</a> | 
        <?php echo linkAction("delcomment",Delete,"&id=".$comment['iId'])?>
    </div>
    <div id="comment_content_<?php echo $comment['iId']?>" style="padding: 5px;"><?php echo $comment['cContent']?></div>
</div>
<?php
}//end for
?>	
<div style="padding-top: 10px; border-bottom:1px solid #dddddd;">
    <strong>Write a comment</strong>
</div>
<div>
    <form name="form_admin" method="post" action="<?php echo formAction('insertcomment')?>">
        <input type="hidden" name="ParentId" value="<?php echo $id?>" />
        <textarea name="comment" class="noeditor"></textarea>
        <br />
        <input type="submit" value="Post comment" /> 
    </form>
</div>

<?php  echo $show_page; ?>

<script>
var formedit=0;
var idold=0;
function editComment(id)
{    
    var show=true;
    if(formedit!=0)
    {
        var pare=getId('comment_content_'+idold);  
        pare.removeChild(formedit);
        formedit=0;
        if(id==idold)show=false;
    }
    if(formedit==0 && show==true)
    {
        var pare=getId('comment_content_'+id);    
        formedit=document.createElement('form');
        inputid=document.createElement("input");
        textcmm=document.createElement('textarea');
        inputsub=document.createElement('input');
        brel    = document.createElement("br");
        formedit.method="post";
        formedit.action="<?php echo formAction('updatecomment')?>";
        formedit.setAttribute("onsubmit","AIM.submit(this,{onComplete:updatesuccess},4)");
        inputid.type="hidden";
        inputid.name="id";
        inputid.value=id;
        textcmm.name="comment";
        textcmm.innerHTML=getId('comment_content_'+id).innerHTML.replace(/<br>/g,"\n");;    
        inputsub.type="submit";
        inputsub.value="Post";
        formedit.appendChild(inputid);
        formedit.appendChild(textcmm);
        formedit.appendChild(brel);
        formedit.appendChild(inputsub);         
        pare.appendChild(formedit);
        idold=id;
    }    
}
function updatesuccess(str,obj)
{
    var pare=getId('comment_content_'+idold);
    var teed=formedit.comment.value.replace(/\n/g,"<br>");
    pare.removeChild(formedit);
    pare.innerHTML=teed;
    formedit=0;
}
function delcomment(id)
{
    ajaxLoader()
}
function delsuccess(str)
{
    
}
</script>